let list = {
	value: 1,
	next: {
		value: 2,
		next: {
			value: 3,
			next: {
				value: 4,
				next: null,
			},
		},
	},
}

printList(list)

// 递归实现：递归解法更简洁
function printList(list) {
	console.log(list.value)
	if (list.next) printList(list.next)
}

console.log('-----')

printList(list)

// 循环实现：循环更高效（没有子调用占用内存消耗资源）
function printList(list) {
	while (list) {
		console.log(list.value)
		list = list.next
	}
}
